//as 用于解决方法名冲突的问题.重命名
import 'package:dio/dio.dart';
import 'package:http/http.dart' as http;
//hide 隐藏某个不要导入的方法
//show 只导入某些内容

import 'dart:io';

 class HttpManager {
   static final Dio dio = Dio();

   static Future <Response> request(String url,int timeOut,
       {String method='get',Map<String, dynamic>? queryParameters}){
     //1.创建配置,什么方式请求
     final options = Options(method: method,receiveTimeout: timeOut*1000);
     //2.发网络请求
     return dio.request(url,queryParameters: queryParameters,options: options);
   }
 }

 // Future<http.Response> get(Uri url, {Map<String,String>? headers}){
 //   return http.get(url,headers: headers);
 // }

Future<Response> get(String url, int timeOut,
{Map<String,dynamic>? headers,
  Map<String,dynamic>? queryParameters,
}){
  //  final dio = Dio();
  //  final options = Options(headers: headers);
  // return dio.get(url,options: options,queryParameters: queryParameters);
  return HttpManager.request(url,timeOut,queryParameters: queryParameters,method: 'get' );
}